<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"/>
    <title>{$appConfigs.title}</title>

    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/{$page_theme | default: 'default'}/easyui.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/style/my.css">
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/javascript/my.js"></script>
    
    <script type="text/javascript" src="{$contextPath}/assets/javascript/my.js"></script>
	<script type="text/javascript" src="{$contextPath}/assets/highcharts/highcharts.js"></script>
	<script type="text/javascript" src="{$contextPath}/assets/highcharts/modules/exporting.js"></script>
	<script type="text/javascript" src="{$contextPath}/assets/highcharts/modules/export-data.js"></script>
</head>
<body style="display:inline-block; width:98%;">
	<div id="container1" class="easyui-panel" title="利润分析" style="width:100%;height:400px;padding:2px;">
	</div>

	<div id="container2" class="easyui-panel" title="成本市值分析" style="width:100%;height:400px;padding:2px;">
	</div>
	
	<div id="container3" class="easyui-panel" title="价格对比图" style="width:100%;height:400px;padding:2px;">
	</div>
	
	<script type="text/javascript">
	var invest_id = {$Request.invest_id};
	{literal}
	$.getJSON('/invest/SummaryInvestDailyService/findSummaryReportByInvestId.do?$value=rows&invest_id=' + invest_id, function(data){
		var categories = new Array();
		var costPrices = new Array(); 		//成本价
		var marketPrices = new Array(); 	//市价
		var buyPrices = new Array(); 	//市价
		var sellPrices = new Array(); 	//市价
		var buyQuantities = new Array();
		var sellQuantities = new Array();
		
		var profits = new Array();			//利润
		var rates = new Array();			//利润率
		
		var markets = new Array();			//市值
		var costs = new Array();			//成本
		
		for(var i=0; i< data.length - 1; i ++) {
			var j = data.length - 1 - i;
			categories[i] 	= data[j].sum_date;

			markets[i] 		= data[j].amount;
			costs[i] 		= data[j].cost;
			costPrices[i]	= data[j].cost_price;
			marketPrices[i]	= data[j].price;
			buyPrices[i] 	= data[j].buy_price;
			sellPrices[i] 	= data[j].sell_price;
			buyQuantities[i]	= data[j].buy_quantity;
			sellQuantities[i]	= data[j].sell_quantity;
			
			profits[i] = data[j].profit;
			rates[i] = parseInt((markets[j] - costs[j]) / costs[j] * 100 * 1000) / 1000;
		}
		data = [
			{name:'利润', type: 'column', yAxis: 0, data:profits}, 
			{name:'利润率', type: 'spline', yAxis: 1, color: '#ff9999', data:rates }]
		rendererProfitChart(categories, data, 'container1');
		
		data = [
			{name:'成本', type: 'spline', color: '#ff8888', data:costs}, 
			{name:'市值', type: 'spline', data:markets}]
		rendererAreaChart(categories, data, 'container2');

		data = [
			{name:'成本价', type: 'spline', color: '#ff8888', data:costPrices}, 
			{name:'市价', type: 'spline', data:marketPrices}, 
			{name:'买入', type: 'scatter', color: '#ff0000', data:buyPrices}, 
			{name:'卖出', type: 'scatter', color: '#00ff00', data:sellPrices}, 
			{name:'买入量', type: 'column', yAxis: 1, color: '#9999ff', data:buyQuantities } , 
			{name:'卖出量', type: 'column', yAxis: 1, color: '#99ff99', data:sellQuantities }
		]
		rendererProfitChart2(categories, data, 'container3', 
				{'title':'价格对比图', 'subtitle':'市价/成本价对比图', 'yAxis_title1':'价格', 'yAxis_title2':'交易量'});
	});
	{/literal}
	</script>
</body>
</html>